﻿using System;
using Fly.Data;
using FlyWebFrame.Model;

namespace FlyWebFrame.Action
{
    public class courses : homeaction
    {
        public int courseId;
        public string title;
        public string level;
        public int duration;
        public string conditions;
        public string functions;
        public string skills;
        public string descriptions;
        public string topics;
        public string attendant;
        public string benefit;
        public string code;

        public dynamic others;

        public override void Treat()
        {
            Int32.TryParse(GetParameter(1), out courseId);
            current_link = "courses/" + other_lang + "/" + courseId;
            content_right = "/html/home/course_template.html";

            this.renderLeftNav(35);

            Courses courses = new Courses();
            courses.id = courseId;
            if (courses.Instance().Status)
            {
                title = courses.title;
                level = courses.level+"";
                duration = courses.duration;
                conditions = courses.conditions;
                functions = courses.functions;
                skills = courses.skills;
                descriptions = courses.descriptions;
                topics = courses.topics;
                attendant = courses.attendant;
                benefit = courses.benefit;
                code = courses.code;

                if (level == "1")
                {
                    level = "Tổng quan";
                }
                else if (level == "2")
                {
                    level = "Nền tảng";
                }
                else if (level == "3") 
                {
                    level = "Nâng cao";
                }
                else if (level == "4")
                {
                    level = "Chuyên ngành";
                }
                if (conditions == null || conditions == "")
                {
                    conditions = "Không";
                }
                else 
                {
                    Result r = courses.GetByIds(conditions);
                    conditions = "";
                    for (int i = 0; i < r.Data.Length; i++) 
                    {
                        conditions += r.Data[i].code+" "+r.Data[i].title + "<br />";
                    }
                }
                big_title = "Khóa học";
                current_title = title;

                others = courses.Get().Data;
            }
        }
    }
}